/*********************************************************************
 * Created by Mercury Interactive Windows Sockets Recorder
 *
 * Created on: Thu Dec 18 13:40:43
 *********************************************************************/

#include "lrs.h"


Action()
{
    char *recvbuf;  
    int recvlen=0;  
    int rc;  
  
    lrs_startup(257);  
  
    lr_start_transaction("Trans_1");  
    lr_start_transaction("Conn_1");  
  
    rc=lrs_create_socket("socket0", "TCP", "RemoteHost=192.168.1.101:8888",  LrsLastArg);//创建Socket连接  
  
    if (rc != 0 ) {     
        lr_end_transaction("Conn_1", LR_FAIL);     
        lr_end_transaction ("Trans_1", LR_FAIL);     
        return 0;    
    }  
    lr_end_transaction("Conn_1", LR_PASS);  //判断socket是否链接成功的事务，0表示创建成功  
  
    lrs_send("socket0", "buf0", LrsLastArg); //发送buf0，buf0为在data.ws中定义的发送变量  
  
    lrs_receive("socket0", "buf1", LrsLastArg); //接收消息，存放在buf1中，buf1是在data.ws中定义的接收数组，注意数组长度一定要大于等于实际接收长度  
  
    lrs_get_last_received_buffer("socket0",&recvbuf,&recvlen);//把Socket最后接收的字节数组，长度放在recvlen中，内容放在recvbuf中  
  
    lr_output_message("Received:%s",lr_eval_string(recvbuf));  
  
    if(recvlen>3)  
        lr_end_transaction("Trans_1", LR_PASS);  
    else  
        lr_end_transaction ("Trans_1", LR_FAIL);  
  
  
    lrs_disable_socket("socket0", DISABLE_SEND_RECV);  
  
    lrs_close_socket("socket0");  


    return 0;
}

